<template>
  <view>
    <view
    :class="{
      'driver-code': true,
      'driver-code-orange': getCodeType(score) === 'orange',
      'driver-code-green': getCodeType(score) === 'green',
      'driver-code-red': getCodeType(score) === 'red'
    }">
      <view
        :class="{
          'code-type': true,
          'code-type-orange': getCodeType(score) === 'orange',
          'code-type-green': getCodeType(score) === 'green',
          'code-type-red': getCodeType(score) === 'red'
        }"
      >
        <text :style="{ color: getCodeType(score) } ">
          <!-- 黄码 -->
          {{ (getCodeType(score) === 'orange') ? '黄码' : (getCodeType(score) === 'green') ? '绿码' : (getCodeType(score) === 'red') ? '红码' : '' }}
        </text>
      </view>
      <view class="code-score">
        <text>
          {{score}}分
        </text>
      </view>
    </view>
  </view>
</template>

<script>
  import { getScoreColor } from '@/common/utils/index.js'
  export default {
    name:"score-tag",
    props: {
      score: {
        type: Number,
        default: 0
      }
    },
    computed: {
      getCodeType () {
        return function (score) {
          return getScoreColor(score)
        }
      }
    },
    data() {
      return {
        
      };
    }
  }
</script>

<style lang="scss">
.driver-code-orange{
  // color: #FEAC40;
  background-color: orange !important;
  border: 1rpx solid orange !important;
}
.driver-code-green{
  background-color: green !important;
  border: 1rpx solid green !important;
}
.driver-code-red{
  background-color: red !important;
  border: 1rpx solid red !important;
}
.driver-code {
  display: flex;
  margin-left: 32rpx;
  align-items: center;
  box-sizing: border-box;
  .code-type-orange{
    background-color: #FFFFFF;
    color: orange;
  }
  .code-type-green{
    background-color: #FFFFFF;              
    color: green;
  }
  .code-type-red{
    background-color: #FFFFFF;
    color: red;
  }
  .code-type {
    background-color: #FFFFFF;
    padding: 0rpx 8rpx;
    box-sizing: border-box;
  }
  .code-score {
    color: #FFFFFF;
    margin: 0rpx 8rpx;
  }
}
</style>
